<template>
  <div>
    <el-form :inline="true" :model="formData">
      <el-form-item>
        <el-input v-model="formData.name" placeholder="输入机构名称或者拼音首字母"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="search" @click="handleSearch('dataGrid')">搜索</el-button>
        <el-button type="primary" icon="plus" @click="handleAdd()">新增</el-button>
      </el-form-item>
    </el-form>

    <Datagrid :data="dataGrid" ref="dataGrid"></Datagrid>
  </div>
</template>

<script>
  import Datagrid from "@/components/Datagrid.vue";
  import {methods} from "@/core";

  export default {
    components: {Datagrid},
    mixins: [methods],
    data () {
      return {
        formData: {name: ""},
        dataGrid: {
          url: "/organization.json",
          deleteUrl: "/organization.json",
          pagination: true,
          align: "center",
          columns: [
            {field: "name", title: "机构", width: 100},
            {field: "type", title: "机构类别"},
            {field: "way", title: "接入方式"},
            {field: "num", title: "前置机数"},
            {field: "appkey", title: "appkey"},
            {field: "state", title: "状态", formatter: row => {
              return row.state ? `<span class="green_circle"></span>` : `<span class="red_circle"></span>`;
            }},
            {field: "", title: "操作", width: 200, operate: [
              {name: "修改", handle: this.handleEdit},
              {name: "删除", handle: this.handleDelete("dataGrid")}
            ]}
          ]
        }
      }
    }
  }
</script>

<style scoped lang="scss">
    .el-form /deep/ .el-input__inner {
      width: 620px;
      border: none;
    }
</style>
